package com.micro.modual.extension;

import com.micro.common.MicroConstant;
import com.micro.common.biz.GeneratorCodeUtil;
import com.micro.common.util.SnowFlakeUtil;
import com.micro.core.handler.BaseContextHandler;
import com.micro.modual.entity.MessageText;
import com.micro.modual.model.bo.messagetext.MessageTextBO;

import java.util.Date;

/**
 * <h1>消息内容表 延展类</h1>
 *
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:23:27
 */
public class MessageTextExtension {

    /**
     * <h2>转换: 消息内容表 新增</h2>
     *
     * @param messageTextBO {@link MessageTextBO} 消息内容表 新增/修改 请求对象
     * @return {@link MessageText} 消息内容表
     */
    public static MessageText converAddMessageText(MessageTextBO messageTextBO) {
        MessageText messageText = new MessageText();
        messageText.setId(SnowFlakeUtil.getId());
        messageText.setCreateTime(new Date());
        messageText.setCreateName(BaseContextHandler.getCustomerName());
        messageText.setIsDelete((byte) 2);
        messageText.setMessageContent(messageTextBO.getMessageContent());
        messageText.setMessageLink(messageTextBO.getMessageLink());
        messageText.setMessageTitle(messageTextBO.getMessageTitle());
        messageText.setModuleName(messageTextBO.getModuleName());
        messageText.setSendType(messageTextBO.getSendType());
        messageText.setSendStatus(messageTextBO.getSendStatus());
        return messageText;
    }

    /**
     * <h2>转换: 消息内容表 修改</h2>
     *
     * @param messageTextBO {@link MessageTextBO} 消息内容表 新增/修改 请求对象
     * @return {@link MessageText} 消息内容表
     */
    public static MessageText converEditMessageText(MessageTextBO messageTextBO) {
        MessageText messageText = new MessageText();
        messageText.setId(messageTextBO.getId());
        messageText.setUpdateTime(new Date());
        messageText.setMessageContent(messageTextBO.getMessageContent());
        messageText.setMessageLink(messageTextBO.getMessageLink());
        messageText.setMessageTitle(messageTextBO.getMessageTitle());
        messageText.setModuleName(messageTextBO.getModuleName());
        messageText.setSendType(messageTextBO.getSendType());
        messageText.setSendStatus(messageTextBO.getSendStatus());
        return messageText;
    }
}
